from threading import Thread
from time import sleep
from random import randint

def run_rept(task, time_interval):
    print task,time_interval

def run_days(func,timelist,task):         
    print func(task),timelist,task
    
def run_hour(func,timestramp,task):
    print func(task),timestramp,task
def test(task):
    print "test gg"
    print task
    return 1
    
class Thread_Rept(Thread):
    """docstring for MyThread"""
    def __init__(self,func=test,task={},time_interval=5,times=[],sche_type=1):
        super(Thread_Rept, self).__init__()
        self.task = task
        self.time_interval =time_interval
        self.type=sche_type
        self.times=times
        self.func=test
    def run(self):
        if(self.type==3):
            run_rept(self.task, self.time_interval)
            print "3"
        elif self.type==2:
            run_days(self.func, self.times,self.task)
            print "2"
        elif self.type==1:
            run_hour(self.func, self.times, self.task)
            print "1"

thread1 = Thread_Rept(task={"id":"3"},time_interval=3,sche_type=3,times=[111])
thread2 = Thread_Rept(func=test,task={"id":"5"},time_interval=5,sche_type=2,times=[333])
thread3 = Thread_Rept(func=test,task={"id":"5"},time_interval=5,sche_type=1,times=111)

thread1.start()
thread2.start()
thread3.start()

